package com.esiag.isidis.marshaling;

import java.net.UnknownHostException;
import com.esiag.isidis.fi.pdsTeam.receive.beans.Action;



public class Marshaling implements IMarshal{

	public byte[] getTrame(Action action) {
		Tram t=Tram.getInstance();
	/*	ActionDao dao = new ActionDaoImpl();
		List<com.esiag.pdsteam.entities.Action> d=dao.findAll();
		for(int i =0;i<d.size();i++)
			System.out.println(d.get(i).toString());*/
	/*	//ActionDAO dao1 = new ActionDAOImpl();
		Action action1;
		//dao1.insert(action1);
		SourceDAO dao = new SourceDAOImpl();
		  System.out.println("ghitah1");
	       Sourcetype type1,type2,type3;
	       Source source1,source2,source3;
	       System.out.println("ghitah2");
	               type1 = new Sourcetype(1, "type1", null);
	               type2 = new Sourcetype(2, "type3", null);
	               type3 = new Sourcetype(3, "type3", null);
	               
	               source1 = new Source(1, type1, "source1", null);
	               source2 = new Source(2, type2, "source2", null);
System.out.println("Source 2 =" + source2);
	dao.insert(source2);
	dao.insert(source1);
	 System.out.println("ghitah3");
		List<Source> list = dao.findAll();
		return t.setTram(type1.getIdSourceType(), source1.getIdSource(), "");
	*/
	return t.setTram(action.getOrder().gettSource(),action.getOrder().getSource(),action.getOrder().getAction());
	}

	public void sendActionBrute(byte[] tab,int typeSource,int idType) {
		RawActionSender rawActionSender;
		try {
			rawActionSender = RawActionSender.getInstance();
			rawActionSender.sendTramExample(tab);
			//(tab,idType);
		} catch (UnknownHostException e) {                       
			e.printStackTrace();
		}
		
	}

}
